#ifndef _CC_UDP_LISTENER_H_
#define _CC_UDP_LISTENER_H_

#include "cache.h"
#include <string.h>
#include "poller.h"
#include "socketNet.h"
#include "GameBase.h"

using namespace comm::sockcommu;

#define MAX_UDP_RECV_LEN            1024*35   //35 kb 

class UdpListener : public CPollerObject
{
public:
	UdpListener(CGameBase* pServer);
	virtual ~UdpListener();
public: //callback
	int Init(){ return 0; }
	int InputNotify();
	//int OutputNotify(void);

public: //method
	virtual int Listen(const char* bindIp, uint16_t port);
	virtual int Send(const char * buff, int len,char* dst_ip,int dst_port);

	inline string GetIP(){return this->_bindAddr;}
	inline uint16_t GetPort(){return this->_bindPort;}; 
public:
	CGameBase* m_pServer;

protected:
	uint16_t	_bindPort;
	char	_bindAddr[128];

private:
	int generate_addr(char *domain, int port, struct sockaddr_in *addr);

	CRawCache       _r;
	CRawCache       _w;
};

#endif

